<div class="member-main">
    <div class="title title2">举报管理</div>
    <{assign var=progress_step value='0'}>
    <{include file='site/common/report_progress.html' app='complain'}>
    <div class="FormWrap" style="background-color:#FFFFFF;border:0 none;padding:0;">
        <div class='col-main'>
            <div class='main-wrap'>
            <div id="WarningBox" class="Accuse">
            <ul>
            <li>1.请提供充分的证据以确保举报成功，请珍惜您的会员权利，帮助客服更好地管理网站；</li>
            <li>2.举报仅针对商品或会员本身，如需处理交易中产生的纠纷，请选择投诉；</li>
            <li>3.同一件商品如果已被其他会员举报，系统会提示您不必重复举报；</li>
            <li>4.您每天对同一店铺最多只能举报4件商品，请放心客服会检查该店铺更多商品。</li>
            <li>5.<font color="#FF3300">&nbsp;*&nbsp;</font>号为必填项。</li>
            </ul>
            </div>
                <form class='boxbase J_BoxTab form-edit J_FormEdit' action="<{link app='complain' ctl='site_seller_reports' act='addSave'}>" method='POST' enctype='multipart/form-data'>
                    <input type='hidden' name='source' value='buyer'>
                    <input type='hidden' name='from_member_id' value='<{$member_info.pam_account.account_id}>'>
                    <input type='hidden' name='to_member_id' value='<{$store_info.account_id}>'>
                    <input type='hidden' name='store_id' value='<{$store_info.store_id}>'>
                    <input type='hidden' name='goods_id' value='<{$goods_id}>'>
                    <input type='hidden' name='from_uname' value='<{$member_info.uname}>'>
                    <input type='hidden' name='to_uname' value='<{$store_info.shop_name}>'>
                    <input type='hidden' name='store_name' value='<{$store_info.store_name}>'>
                    <div class="box-bd">
                         <div class="row-item first-row-item">
                            <div class="ctitle">
                                <label>被举报者：</label>
                            </div>
                            <div class="info J_ReasonBox">
                               <{$store_info.store_name}>
                            </div>
                            
                        </div>
                         <div class="row-item first-row-item">
                            <div class="ctitle">
                                <label>相关商品：</label>
                            </div>
                            <div class="info J_ReasonBox">
                             <{$goods_name}>
                            </div>
                            
                        </div>

                        <div class="row-item first-row-item">
                            <div class="ctitle">
                                <b>*</b><label>举报类型：</label>
                            </div>
                            <div class="info J_ReasonBox">
                                <{input vtype="required"  type="select"  rows=$reports_cat  valueColumn="cat_id" labelColumn="cat_name"   name="cat_id"  id="ot"   }>
                            </div>
                        </div>
                        <div class="row-item first-row-item">
                            <div class="ctitle">
                                <label>手机：</label>
                            </div>
                            <div class="info J_ReasonBox">
                                <input style="height: 20px;" value="" name="mobile" class="J_Phone">
                            </div>
                            
                        </div>
                        <div class="row-item first-row-item clear-fix">
                            <div class="ctitle">
                                <b>*</b><label>补充留言：</label>
                            </div>
                            <div class="info">
                                <textarea  class="introduction J_FormVerify_Textarea J_FormVerify" name="memo" placeholder="补充留言不能为空！"></textarea>
                                <div style="padding-left:236px;" class="help-msg">
                                <strong style="padding-left:115px;" class="text-count J_TextCount" style='font-weight:bold;'>300</strong>/300字
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="box-bd">
                        <div class="row-item first-row-item clear-fix">
                            <div class="ctitle">
                                <b>*</b><label>上传凭证：</label>
                            </div>
                            <div class="info" id='J_WaitItems'>
                              
                            </div>
                            <div class='info upload-image-wrap J_UploadWrap'>
                            <a id='J_SelectFileLabel' class=" select-file-link <{if $isIE}>select-file-label-ie<{/if}>" href="#" style='color: #0579c6;'>选择要上传的凭证</a>
                            <div id='J_FileInputBox' class="select-file-wrap <{if $isIE}>select-file-wrap-ie<{/if}>">
                                <input type="file" size="1" class="select-file J_SelectFile" name="image[]" accept="image/gif,image/jpeg,image/jpg,image/bmp,image/png">
                            </div>
                            </div>
                            <div class="row-item help-msg-wrap">
                                    <div class="info">
                                        <div class="J_VadioHelpMsg help-msg  hidden">图片、音频文件不超过5M，图片支持GIF，JPG，JPEG，PNG，BMP格式；音频文件支持WAV，AMR，AIFF，WMA，M4R格式；凭证数量最多3张</div>
                                        <div class="J_ImgHelpMsg help-msg">每张图片不超过5M，最多3张，支持GIF，JPG，JPEG，PNG，BMP格式</div>
                                    </div>
                                </div>
                        </div>
                    </div>
                    <div class="box-bd">
                    <div class="row-item first-row-item clear-fix">
                    <div class='info'>                     
                       <button id='J_Submit' type='button' class="btn">提交</button>
                       &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a target="_blank" href="<{link app='content' ctl=site_article act=index arg0=35}>" style="color:blue;">规则详情>></a>
                       </div>

                    </div>
                    </div>
                </form>
            </div>
        </div>
       
    </div>
</div>

<script>
(function(){
    
    FileUpload=new Object();
    Object.append(FileUpload,{
        init:function(){
           <{if $isIE}>
              var arr_file=this.getFileInput();
              var last=arr_file.getLast();
              last.addEvent('change',this.fileChange.bind(this));
           <{else}>
           $('J_SelectFileLabel').addEvent('click',function(e){
              e.stop();
              var arr_file=this.getFileInput();
              var last=arr_file.getLast();
              if(!last.retrieve('add:change')){
                    last.addEvent('change',this.fileChange.bind(this));
                    last.store('add:change',true);
              }
              last.click();
           }.bind(this));
           <{/if}>
          
           if(document.getElement('.J_FormVerify_Textarea')){
            document.getElement('.J_FormVerify_Textarea').addEvent('keyup',function(e){
                var length=300-this.value.length;
                document.getElement('.J_TextCount').set('html',length);
            });
           }
           $('J_Submit').addEvent('click',function(e){
                e.stop();
                var form=e.target.getParent('form');
                var J_FormVerify_Textarea=form.getElement('.J_FormVerify_Textarea');
                if(J_FormVerify_Textarea.value.trim()==''){
                    J_FormVerify_Textarea.focus();
                    Message.error('请输入补充留言！');
                    return;
                }else{
                   if(J_FormVerify_Textarea.value.trim().length>300){
                       Message.error('留言字数不能大于300个！');
                       return;
                   }
                }
                
                var items=$('J_WaitItems').getElements('.J_WaitItem');
                if(items.length<=0){
                    Message.error('请最少上传一张凭证！');
                    return;
                }
                var inputFiles=$('J_FileInputBox').getElements('.J_SelectFile');
                inputFiles.each(function(el){
                  if(el.value.trim()==''){
                     el.destroy();
                  }
                });
                form.submit();
           
           }.bind(this));
        },
        getFileInput:function(){
            return $('J_FileInputBox').getElements('.J_SelectFile');
        },
        fileChange:function(e){
            var obj=e.target;
            var v=obj.value;
            var $arr=['JPG','JPEG','GIF','PNG','BMP'];
               if(v){
                   var ext=v.split('.').getLast();
                   if($arr.contains(ext.toUpperCase())==false){
                        obj.value='';
                        Message.error('只能上传GIF，JPG，JPEG，PNG，BMP格式');
                        return;
                   }
               }
            var item=this.newWaitItem(v);
            item.inject($('J_WaitItems'));
            if(this.getFileInput().length>=3){
               $('J_SelectFileLabel').hide();
               return;
            }
            var inputFile=this.newFileInput();
            inputFile.inject($('J_FileInputBox'));
        },
        newFileInput:function(){
           var inputFile=new Element('input');
            inputFile.set('type','file');
            inputFile.addClass('select-file');
            inputFile.addClass('J_SelectFile');
            inputFile.set('name','image[]');
            inputFile.set('size','1');
            inputFile.set('accept','image/gif,image/jpeg,image/jpg,image/bmp,image/png');
            inputFile.addEvent('change',this.fileChange.bind(this));
            inputFile.store('add:change',true);
            return inputFile;
        },
        newWaitItem:function(filename){
            var el=new Element('div');
            el.addClass('J_WaitItem');
            el.set('html','<span class="file-name">'+filename+'</span><span> <a class="J_Delete delete" href="#" onclick="FileUpload.deleteWaitItem(new Event(event));"  data-file-idx="1">删除</a></span>');
            return el;
        },
        deleteWaitItem:function(e){
            e.stop();
            var obj=e.target;
            var waitItem=$(obj).getParent('.J_WaitItem');
            var items=$('J_WaitItems').getElements('.J_WaitItem');
            var inputFiles=$('J_FileInputBox').getElements('.J_SelectFile');
            
            var index=items.indexOf(waitItem);
            var inputFile=inputFiles[index];
            inputFile.destroy();
            waitItem.destroy();
            if(inputFiles.length<=1){
                var ninputFile=this.newFileInput();
                ninputFile.inject($('J_FileInputBox'));
            }                
            $('J_SelectFileLabel').show();
        }
        
        
    });
    FileUpload.init();

})();
</script>